{
  "nbformat_minor": 0,
  "nbformat": 4,
  "cells": [
    {
      "source": [
        "#### Copyright 2017 Google LLC."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "copyright-notice"
      }
    },
    {
      "execution_count": 0,
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "copyright-notice2",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        },
        "cellView": "both"
      },
      "outputs": [],
      "source": [
        "# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
        "# you may not use this file except in compliance with the License.\n",
        "# You may obtain a copy of the License at\n",
        "#\n",
        "# https://www.apache.org/licenses/LICENSE-2.0\n",
        "#\n",
        "# Unless required by applicable law or agreed to in writing, software\n",
        "# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
        "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
        "# See the License for the specific language governing permissions and\n",
        "# limitations under the License."
      ]
    },
    {
      "source": [
        " # Pandas \uac04\ub2e8 \uc18c\uac1c"
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "rHLcriKWLRe4"
      }
    },
    {
      "source": [
        "**\ud559\uc2b5 \ubaa9\ud45c:**\n",
        "  * *pandas* \ub77c\uc774\ube0c\ub7ec\ub9ac\uc758 `DataFrame` \ubc0f `Series` \ub370\uc774\ud130 \uad6c\uc870\uc5d0 \uad00\ud55c \uc18c\uac1c \ud655\uc778\ud558\uae30\n",
        "  * `DataFrame` \ubc0f `Series` \ub0b4\uc758 \ub370\uc774\ud130 \uc561\uc138\uc2a4 \ubc0f \uc870\uc791\n",
        "  * *pandas* `DataFrame`\uc73c\ub85c CSV \ub370\uc774\ud130 \uac00\uc838\uc624\uae30\n",
        "  * `DataFrame`\uc758 \uc0c9\uc778\uc744 \ub2e4\uc2dc \uc0dd\uc131\ud558\uc5ec \ub370\uc774\ud130 \uc154\ud50c"
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "QvJBqX8_Bctk"
      }
    },
    {
      "source": [
        " [*Pandas*](http://Pandas.pydata.org/)\ub294 \uc5f4 \uc911\uc2ec \ub370\uc774\ud130 \ubd84\uc11d API\uc785\ub2c8\ub2e4. \uc785\ub825 \ub370\uc774\ud130\ub97c \ucc98\ub9ac\ud558\uace0 \ubd84\uc11d\ud558\ub294 \ub370 \ud6a8\uacfc\uc801\uc778 \ub3c4\uad6c\uc774\uba70, \uc5ec\ub7ec ML \ud504\ub808\uc784\uc6cc\ud06c\uc5d0\uc11c\ub3c4 *Pandas* \ub370\uc774\ud130 \uad6c\uc870\ub97c \uc785\ub825\uc73c\ub85c \uc9c0\uc6d0\ud569\ub2c8\ub2e4.\n",
        "*Pandas* API\ub97c \uc804\uccb4\uc801\uc73c\ub85c \uc18c\uac1c\ud558\ub824\uba74 \uae38\uc5b4\uc9c0\uaca0\uc9c0\ub9cc \uc911\uc694\ud55c \uac1c\ub150\uc740 \uaf64 \uac04\ub2e8\ud558\ubbc0\ub85c \uc544\ub798\uc5d0\uc11c \uc18c\uac1c\ud558\ub3c4\ub85d \ud558\uaca0\uc2b5\ub2c8\ub2e4. \uc804\uccb4 \ub0b4\uc6a9\uc744 \ucc38\uc870\ud560 \uc218 \uc788\ub3c4\ub85d [*Pandas* \ubb38\uc11c \uc0ac\uc774\ud2b8](http://pandas.pydata.org/pandas-docs/stable/index.html)\uc5d0\uc11c \uad11\ubc94\uc704\ud55c \ubb38\uc11c\uc640 \uc5ec\ub7ec \uac00\uc774\ub4dc\ub97c \uc81c\uacf5\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "TIFJ83ZTBctl"
      }
    },
    {
      "source": [
        " ## \uae30\ubcf8 \uac1c\ub150\n",
        "\n",
        "\ub2e4\uc74c \ud589\uc740 *Pandas* API\ub97c \uac00\uc838\uc640\uc11c API \ubc84\uc804\uc744 \ucd9c\ub825\ud569\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "s_JOISVgmn9v"
      }
    },
    {
      "source": [
        "from __future__ import print_function\n\n",
        "import pandas as pd\n",
        "pd.__version__"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "aSRYu62xUi3g",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " *Pandas*\uc758 \uae30\ubcf8 \ub370\uc774\ud130 \uad6c\uc870\ub294 \ub450 \uac00\uc9c0 \ud074\ub798\uc2a4\ub85c \uad6c\ud604\ub429\ub2c8\ub2e4.\n",
        "\n",
        "  * **`DataFrame`**\uc740 \ud589 \ubc0f \uc774\ub984 \uc9c0\uc815\ub41c \uc5f4\uc774 \ud3ec\ud568\ub41c \uad00\uacc4\ud615 \ub370\uc774\ud130 \ud14c\uc774\ube14\uc774\ub77c\uace0 \uc0dd\uac01\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\n",
        "  * **`Series`**\ub294 \ud558\ub098\uc758 \uc5f4\uc785\ub2c8\ub2e4. `DataFrame`\uc5d0\ub294 \ud558\ub098 \uc774\uc0c1\uc758 `Series`\uc640 \uac01 `Series`\uc758 \uc774\ub984\uc774 \ud3ec\ud568\ub429\ub2c8\ub2e4.\n",
        "\n",
        "\ub370\uc774\ud130 \ud504\ub808\uc784\uc740 \ub370\uc774\ud130 \uc870\uc791\uc5d0 \uc77c\ubc18\uc801\uc73c\ub85c \uc0ac\uc6a9\ud558\ub294 \ucd94\uc0c1\ud654\uc785\ub2c8\ub2e4. [Spark](https://spark.apache.org/) \ubc0f [R](https://www.r-project.org/about.html)\uc5d0 \uc720\uc0ac\ud55c \uad6c\ud604\uc774 \uc874\uc7ac\ud569\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "daQreKXIUslr"
      }
    },
    {
      "source": [
        " `Series`\ub97c \ub9cc\ub4dc\ub294 \ud55c \uac00\uc9c0 \ubc29\ubc95\uc740 `Series` \uac1d\uccb4\ub97c \ub9cc\ub4dc\ub294 \uac83\uc785\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uba74 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "fjnAk1xcU0yc"
      }
    },
    {
      "source": [
        "pd.Series(['San Francisco', 'San Jose', 'Sacramento'])"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "DFZ42Uq7UFDj",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " `DataFrame` \uac1d\uccb4\ub294 `string` \uc5f4 \uc774\ub984\uacfc \ub9e4\ud551\ub418\ub294 'dict'\ub97c \uac01\uac01\uc758 `Series`\uc5d0 \uc804\ub2ec\ud558\uc5ec \ub9cc\ub4e4 \uc218 \uc788\uc2b5\ub2c8\ub2e4. `Series`\uc758 \uae38\uc774\uac00 \uc77c\uce58\ud558\uc9c0 \uc54a\ub294 \uacbd\uc6b0, \ub204\ub77d\ub41c \uac12\uc740 \ud2b9\uc218 [NA/NaN](http://pandas.pydata.org/pandas-docs/stable/missing_data.html) \uac12\uc73c\ub85c \ucc44\uc6cc\uc9d1\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uba74 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "U5ouUp1cU6pC"
      }
    },
    {
      "source": [
        "city_names = pd.Series(['San Francisco', 'San Jose', 'Sacramento'])\n",
        "population = pd.Series([852469, 1015785, 485199])\n",
        "\n",
        "pd.DataFrame({ 'City name': city_names, 'Population': population })"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "avgr6GfiUh8t",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " \ud558\uc9c0\ub9cc \ub300\ubd80\ubd84\uc758 \uacbd\uc6b0 \uc804\uccb4 \ud30c\uc77c\uc744 `DataFrame`\uc73c\ub85c \ub85c\ub4dc\ud569\ub2c8\ub2e4. \ub2e4\uc74c \uc608\ub294 \uce98\ub9ac\ud3ec\ub2c8\uc544 \ubd80\ub3d9\uc0b0 \ub370\uc774\ud130\uac00 \uc788\ub294 \ud30c\uc77c\uc744 \ub85c\ub4dc\ud569\ub2c8\ub2e4. \ub2e4\uc74c \uc140\uc744 \uc2e4\ud589\ud558\uc5ec \ub370\uc774\ud130\uc5d0 \ub85c\ub4dc\ud558\uace0 \uae30\ub2a5 \uc815\uc758\ub97c \ub9cc\ub4e4\uc5b4 \ubcf4\uc138\uc694."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "oa5wfZT7VHJl"
      }
    },
    {
      "source": [
        "california_housing_dataframe = pd.read_csv(\"https://download.mlcc.google.com/mledu-datasets/california_housing_train.csv\", sep=\",\")\n",
        "california_housing_dataframe.describe()"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "av6RYOraVG1V",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " \uc704\uc758 \uc608\uc5d0\uc11c\ub294 `DataFrame.describe`\ub97c \uc0ac\uc6a9\ud558\uc5ec `DataFrame`\uc5d0 \uad00\ud55c \ud765\ubbf8\ub85c\uc6b4 \ud1b5\uacc4\ub97c \ubcf4\uc5ec\uc90d\ub2c8\ub2e4. \ub610 \ub2e4\ub978 \uc720\uc6a9\ud55c \ud568\uc218\ub294 `DataFrame.head`\ub85c, `DataFrame` \ub808\ucf54\ub4dc \uc911 \ucc98\uc74c \uba87 \uac1c\ub9cc \ud45c\uc2dc\ud569\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "WrkBjfz5kEQu"
      }
    },
    {
      "source": [
        "california_housing_dataframe.head()"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "s3ND3bgOkB5k",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " *Pandas*\uc758 \ub610 \ub2e4\ub978 \uac15\ub825\ud55c \uae30\ub2a5\uc740 \uadf8\ub798\ud551\uc785\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4 `DataFrame.hist`\ub97c \uc0ac\uc6a9\ud558\uba74 \ud55c \uc5f4\uc5d0\uc11c \uac12\uc758 \ubd84\ud3ec\ub97c \ube60\ub974\uac8c \uac80\ud1a0\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "w9-Es5Y6laGd"
      }
    },
    {
      "source": [
        "california_housing_dataframe.hist('housing_median_age')"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "nqndFVXVlbPN",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " ## \ub370\uc774\ud130 \uc561\uc138\uc2a4\n",
        "\n",
        "\uc775\uc219\ud55c Python dict/list \uc791\uc5c5\uc744 \uc0ac\uc6a9\ud558\uc5ec `DataFrame` \ub370\uc774\ud130\uc5d0 \uc561\uc138\uc2a4\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "XtYZ7114n3b-"
      }
    },
    {
      "source": [
        "cities = pd.DataFrame({ 'City name': city_names, 'Population': population })\n",
        "print(type(cities['City name']))\n",
        "cities['City name']"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "_TFm7-looBFF",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        "print(type(cities['City name'][1]))\n",
        "cities['City name'][1]"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "V5L6xacLoxyv",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        "print(type(cities[0:2]))\n",
        "cities[0:2]"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "gcYX1tBPugZl",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " \ub610\ud55c *Pandas*\ub294 \uace0\uae09 [\uc0c9\uc778 \uc0dd\uc131 \ubc0f \uc120\ud0dd](http://Pandas.pydata.org/Pandas-docs/stable/indexing.html) \uae30\ub2a5\uc744 \uc704\ud55c \ud48d\ubd80\ud55c API\ub97c \uc81c\uacf5\ud569\ub2c8\ub2e4. \uc774 \ub0b4\uc6a9\uc740 \ub108\ubb34 \uad11\ubc94\uc704\ud558\ubbc0\ub85c \uc5ec\uae30\uc5d0\uc11c \ub2e4\ub8e8\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "65g1ZdGVjXsQ"
      }
    },
    {
      "source": [
        " ## \ub370\uc774\ud130 \uc870\uc791\n",
        "\n",
        "Python\uc758 \uae30\ubcf8 \uc0b0\uc220 \uc5f0\uc0b0\uc744 `Series`\uc5d0 \uc801\uc6a9\ud560 \uc218\ub3c4 \uc788\uc2b5\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uba74 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "RM1iaD-ka3Y1"
      }
    },
    {
      "source": [
        "population / 1000."
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "XWmyCFJ5bOv-",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " [NumPy](http://www.numpy.org/)\ub294 \uc720\uba85\ud55c \uacc4\uc0b0\uacfc\ud559 \ud234\ud0b7\uc785\ub2c8\ub2e4. *Pandas* `Series`\ub294 \ub300\ubd80\ubd84\uc758 NumPy \ud568\uc218\uc5d0 \uc778\uc218\ub85c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "TQzIVnbnmWGM"
      }
    },
    {
      "source": [
        "import numpy as np\n",
        "\n",
        "np.log(population)"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "ko6pLK6JmkYP",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " \ub354 \ubcf5\uc7a1\ud55c \ub2e8\uc77c \uc5f4 \ubcc0\ud658\uc5d0\ub294 `Series.apply`\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. Python [map \ud568\uc218](https://docs.python.org/2/library/functions.html#map)\ucc98\ub7fc, \n",
        "`Series.apply`\ub294 \uc778\uc218\ub85c [lambda \ud568\uc218](https://docs.python.org/2/tutorial/controlflow.html#lambda-expressions)\ub97c \ud5c8\uc6a9\ud558\uba70, \uc774\ub294 \uac01 \uac12\uc5d0 \uc801\uc6a9\ub429\ub2c8\ub2e4.\n",
        "\n",
        "\uc544\ub798\uc758 \uc608\uc5d0\uc11c\ub294 `\uc778\uad6c`\uac00 \ubc31\ub9cc \uba85\uc744 \ucd08\uacfc\ud558\ub294\uc9c0 \ub098\ud0c0\ub0b4\ub294 \uc0c8 `Series`\ub97c \ub9cc\ub4ed\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "xmxFuQmurr6d"
      }
    },
    {
      "source": [
        "population.apply(lambda val: val > 1000000)"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "Fc1DvPAbstjI",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " \n",
        "`DataFrames` \uc218\uc815 \uc5ed\uc2dc \uac04\ub2e8\ud569\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4 \ub2e4\uc74c \ucf54\ub4dc\ub294 \uae30\uc874 `DataFrame`\uc5d0 \ub450 \uac1c\uc758 `Series`\ub97c \ucd94\uac00\ud569\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "ZeYYLoV9b9fB"
      }
    },
    {
      "source": [
        "cities['Area square miles'] = pd.Series([46.87, 176.53, 97.92])\n",
        "cities['Population density'] = cities['Population'] / cities['Area square miles']\n",
        "cities"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "0gCEX99Hb8LR",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " ## \uc2e4\uc2b5 #1\n",
        "\n",
        "\ub2e4\uc74c \ub450 \uba85\uc81c *\ubaa8\ub450* True\uc778 \uacbd\uc6b0\uc5d0\ub9cc True\uc778 \uc0c8 \ubd80\uc6b8 \uc5f4\uc744 \ucd94\uac00\ud558\uc5ec `\ub3c4\uc2dc` \ud14c\uc774\ube14\uc744 \uc218\uc815\ud569\ub2c8\ub2e4.\n",
        "\n",
        "  * \ub3c4\uc2dc \uc774\ub984\uc740 \uc131\uc778\uc758 \uc774\ub984\uc744 \ubcf8\ub530\uc11c \uc9c0\uc5c8\ub2e4.\n",
        "  * \ub3c4\uc2dc \uba74\uc801\uc774 130\uc81c\uacf1\ud0ac\ub85c\ubbf8\ud130\ubcf4\ub2e4 \ub113\ub2e4.\n",
        "\n",
        "**\ucc38\uace0:** \ubd80\uc6b8 `Series`\ub294 \uae30\uc874 \ubd80\uc6b8 \uc5f0\uc0b0\uc790\uac00 \uc544\ub2cc \ube44\ud2b8 \uc5f0\uc0b0\uc790\ub97c \uc0ac\uc6a9\ud558\uc5ec \uacb0\ud569\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4 *logical and*\ub97c \uc2e4\ud589\ud560 \ub54c `and` \ub300\uc2e0 `&`\ub97c \uc0ac\uc6a9\ud569\ub2c8\ub2e4.\n",
        "\n",
        "**\ucc38\uace0:** \uc2a4\ud398\uc778\uc5b4\uc5d0\uc11c \"San\"\uc740 \"\uc131\uc778\"\uc758 \uc758\ubbf8\uc785\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "6qh63m-ayb-c"
      }
    },
    {
      "source": [
        "# Your code here"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "zCOn8ftSyddH",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " ### \ud574\uacb0 \ubc29\ubc95\n",
        "\n",
        "\ud574\uacb0 \ubc29\ubc95\uc744 \ubcf4\ub824\uba74 \uc544\ub798\ub97c \ud074\ub9ad\ud558\uc138\uc694."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "YHIWvc9Ms-Ll"
      }
    },
    {
      "source": [
        "cities['Is wide and has saint name'] = (cities['Area square miles'] > 50) & cities['City name'].apply(lambda name: name.startswith('San'))\n",
        "cities"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "T5OlrqtdtCIb",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " ## \uc0c9\uc778\n",
        "`Series`\uc640 `DataFrame` \uac1d\uccb4 \ubaa8\ub450 \uc2dd\ubcc4\uc790 \uac12\uc744 \uac01 `Series` \ud56d\ubaa9\uc774\ub098 `DataFrame` \ud589\uc5d0 \ud560\ub2f9\ud558\ub294 `index` \uc18d\uc131\uc744 \uc815\uc758\ud569\ub2c8\ub2e4. \n",
        "\n",
        "\uae30\ubcf8\uc801\uc73c\ub85c \uc0dd\uc131 \uc2dc *Pandas*\ub294 \uc18c\uc2a4 \ub370\uc774\ud130\uc758 \uc21c\uc11c\ub97c \ub098\ud0c0\ub0b4\ub294 \uc0c9\uc778 \uac12\uc744 \ud560\ub2f9\ud569\ub2c8\ub2e4. \uc0dd\uc131\ub41c \uc774\ud6c4 \uc0c9\uc778 \uac12\uc740 \uace0\uc815\ub429\ub2c8\ub2e4. \uc989, \ub370\uc774\ud130\uc758 \uc21c\uc11c\uac00 \uc7ac\uc815\ub82c\ub420 \ub54c \ubcc0\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "f-xAOJeMiXFB"
      }
    },
    {
      "source": [
        "city_names.index"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "2684gsWNinq9",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        "cities.index"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "F_qPe2TBjfWd",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " `DataFrame.reindex`\ub97c \ud638\ucd9c\ud558\uc5ec \uc218\ub3d9\uc73c\ub85c \ud589\uc758 \uc21c\uc11c\ub97c \uc7ac\uc815\ub82c\ud569\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4 \ub2e4\uc74c\uc740 \ub3c4\uc2dc \uc774\ub984\uc744 \uae30\uc900\uc73c\ub85c \ubd84\ub958\ud558\ub294 \uac83\uacfc \ud6a8\uacfc\uac00 \uac19\uc2b5\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "hp2oWY9Slo_h"
      }
    },
    {
      "source": [
        "cities.reindex([2, 0, 1])"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "sN0zUzSAj-U1",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " \uc0c9\uc778 \uc7ac\uc0dd\uc131\uc740 `DataFrame`\uc744 \uc11e\uae30(\uc784\uc758 \uc124\uc815\ud558\uae30) \uc704\ud55c \uc88b\uc740 \ubc29\ubc95\uc785\ub2c8\ub2e4. \uc544\ub798\uc758 \uc608\uc5d0\uc11c\ub294 \ubc30\uc5f4\ucc98\ub7fc \ub41c \uc0c9\uc778\uc744 NumPy\uc758 `random.permutation` \ud568\uc218\uc5d0 \uc804\ub2ec\ud558\uc5ec \uac12\uc744 \uc11e\uc2b5\ub2c8\ub2e4. \uc774\ub807\uac8c \uc11e\uc778 \ubc30\uc5f4\ub85c `reindex`\ub97c \ud638\ucd9c\ud558\uba74 `DataFrame` \ud589\ub3c4 \uac19\uc740 \ubc29\uc2dd\uc73c\ub85c \uc11e\uc785\ub2c8\ub2e4.\n",
        "\ub2e4\uc74c \uc140\uc744 \uc5ec\ub7ec \ubc88 \uc2e4\ud589\ud574 \ubcf4\uc138\uc694."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "-GQFz8NZuS06"
      }
    },
    {
      "source": [
        "cities.reindex(np.random.permutation(cities.index))"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "mF8GC0k8uYhz",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " \uc790\uc138\ud55c \uc815\ubcf4\ub294 [\uc0c9\uc778 \ubb38\uc11c](http://pandas.pydata.org/pandas-docs/stable/indexing.html#index-objects)\ub97c \ucc38\uc870\ud558\uc138\uc694."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "fSso35fQmGKb"
      }
    },
    {
      "source": [
        " ## \uc2e4\uc2b5 #2\n",
        "\n",
        "`reindex` \uba54\uc11c\ub4dc\ub294 \uc6d0\ub798 `DataFrame`\uc758 \uc0c9\uc778 \uac12\uc5d0 \uc5c6\ub294 \uc0c9\uc778 \uac12\uc744 \ud5c8\uc6a9\ud569\ub2c8\ub2e4. \uba54\uc11c\ub4dc\ub97c \uc2e4\ud589\ud574\ubcf4\uace0 \uc774\ub7f0 \uac12\uc744 \uc0ac\uc6a9\ud558\uba74 \uc5b4\ub5a4 \uacb0\uacfc\uac00 \ub098\uc624\ub294\uc9c0 \ud655\uc778\ud574\ubcf4\uc138\uc694. \uc65c \uc774\ub7f0 \uac12\uc774 \ud5c8\uc6a9\ub41c\ub2e4\uace0 \uc0dd\uac01\ud558\ub098\uc694?"
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "8UngIdVhz8C0"
      }
    },
    {
      "source": [
        "# Your code here"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "PN55GrDX0jzO",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " ### \ud574\uacb0 \ubc29\ubc95\n",
        "\n",
        "\ud574\uacb0 \ubc29\ubc95\uc744 \ubcf4\ub824\uba74 \uc544\ub798\ub97c \ud074\ub9ad\ud558\uc138\uc694."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "TJffr5_Jwqvd"
      }
    },
    {
      "source": [
        " `reindex` \uc785\ub825 \ubc30\uc5f4\uc5d0 \uc6d0\ub798 `DataFrame` \uc0c9\uc778 \uac12\uc5d0 \uc5c6\ub294 \uac12\uc744 \ud3ec\ud568\ud558\uba74 `reindex`\uac00 \uc774 \\'\ub204\ub77d\ub41c\\' \uc0c9\uc778\uc5d0 \uc0c8 \ud589\uc744 \ucd94\uac00\ud558\uace0 \ubaa8\ub4e0 \ud574\ub2f9 \uc5f4\uc744 `NaN` \uac12\uc73c\ub85c \ucc44\uc6c1\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "8oSvi2QWwuDH"
      }
    },
    {
      "source": [
        "cities.reindex([0, 4, 5, 2])"
      ],
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "yBdkucKCwy4x",
        "colab": {
          "autoexec": {
            "wait_interval": 0,
            "startup": false
          }
        }
      },
      "outputs": [],
      "execution_count": 0
    },
    {
      "source": [
        " \uc0c9\uc778\uc740 \ubcf4\ud1b5 \uc2e4\uc81c \ub370\uc774\ud130\uc5d0\uc11c \uac00\uc838\uc628 \ubb38\uc790\uc5f4\uc774\uae30 \ub54c\ubb38\uc5d0 \uc774 \ub3d9\uc791\uc774 \ubc14\ub78c\uc9c1\ud569\ub2c8\ub2e4([*Pandas* \uc0c9\uc778 \uc7ac\uc0dd\uc131 \ubb38\uc11c](http://Pandas.pydata.org/Pandas-docs/stable/generated/Pandas.DataFrame.reindex.html)\uc5d0\uc11c \uc0c9\uc778 \uac12\uc774 \ube0c\ub77c\uc6b0\uc800 \uc774\ub984\uc778 \uc608\uc81c \ucc38\uc870).\n",
        "\n",
        "\uc774 \uacbd\uc6b0 \\'\ub204\ub77d\ub41c\\' \uc0c9\uc778\uc744 \ud5c8\uc6a9\ud558\uba74 \uc678\ubd80 \ubaa9\ub85d\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc27d\uac8c \uc0c9\uc778\uc744 \ub2e4\uc2dc \uc0dd\uc131\ud560 \uc218 \uc788\uc73c\ubbc0\ub85c, \uc785\ub825 \ucc98\ub9ac\uc5d0 \ub300\ud574 \uac71\uc815\ud558\uc9c0 \uc54a\uc544\ub3c4 \ub429\ub2c8\ub2e4."
      ],
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "2l82PhPbwz7g"
      }
    }
  ],
  "metadata": {
    "colab": {
      "default_view": {},
      "version": "0.3.2",
      "collapsed_sections": [
        "YHIWvc9Ms-Ll",
        "TJffr5_Jwqvd",
        "copyright-notice"
      ],
      "name": "intro_to_pandas.ipynb",
      "views": {}
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  }
}
